package com.buildings.util;

import android.content.Context;
import android.net.Uri;
import android.os.Environment;

import com.buildings.R;

/**
 * 文件相关常量
 *
 * @author sy
 */
public class HYFileConstant {

    /**
     * 首次登陆验证目录
     */
    public static String RES_FIRST_DATA = "";

    /**
     * app文件夹
     */
    public static String APP_PATH = "";

    /**
     * zip下载路径(大文件存储路径)
     */
    public static String DOWNLOAD_PATH = "";

    /**
     * 图片缓存路径(sd卡)
     */
    public static String IMG_PATH = "";

    /**
     * 图片缓存路径(data目录)
     */
    public static String IMG_APP_PATH = "";

    /**
     * sd卡是否存在
     */
    public boolean sdCardIsExist;

    /**
     * SD卡路径
     */
    public static String SD_PATH;
    /**
     * 存放CRASH文件
     */
    public static String CRASH_PATH;
    /**
     * 存放下载的APK包
     */
    public static String DWONLOAD_PATH;

    /**
     * 地图相关缓存
     */
    public static String MAP_PATH;

    /**
     *
     */
    public static String LOOK_IAMGE_PATH;


    /**
     * 客户端是否是首次启动
     */
    public static boolean isFirstStartUp = true;

    /**
     * 当前接入点uri
     */
    public static final Uri PREFERRED_APN_URI = Uri
            .parse("content://telephony/carriers/preferapn");

    /**
     * 录音上传缓存路径(sd卡)
     */
    public static String UPLOAD_AUDIO_PATH = "";

    /**
     * 图片上传缓存路径(sd卡)
     */
    public static String UPLOAD_PHOTO_PATH = "";

    /**
     * 视频上传缓存路径(sd卡)
     */
    public static String UPLOAD_VIDEO_PATH = "";


    /**
     * 拍照
     */
    public static final int PHOTOCAPTURE = 1;

    /**
     * 相册
     */
    public static final int PHOTOALBUM = 2;

    /**
     * 缩放 结果
     */
    public static final int PHOTORESOULT = 3;

    /**
     * 视频录制
     */
    public static final int VIDEORECORD = 4;

    /**
     * 视频播放
     */
    public static final int VIDEOSHOW = 5;

    public HYFileConstant(Context context, String app_name) {

        String stonePathName = context.getResources().getString(R.string.app_name);
        RES_FIRST_DATA = "/data/data/" + context.getPackageName() + "/first/";
        APP_PATH = "/" + app_name + "/";
        DOWNLOAD_PATH = APP_PATH + stonePathName + "/";
        IMG_PATH = APP_PATH + "temp/";
        IMG_APP_PATH = "/data/data/" + context.getPackageName() + "/temp/";
        UPLOAD_PHOTO_PATH = APP_PATH + "uploadPhoto/";
        UPLOAD_AUDIO_PATH = APP_PATH + "uploadAudio/";
        UPLOAD_VIDEO_PATH = APP_PATH + "uploadVideo/";
        SD_PATH = getSDPath();
        CRASH_PATH = APP_PATH + "crash/";
        DWONLOAD_PATH = APP_PATH + "downloadApk/";
        MAP_PATH = APP_PATH + "map/";
        LOOK_IAMGE_PATH = "/DCIM/看现场";
    }

    /**
     * @param sdCardIsExist
     * @param sd_path
     */
    public void setSD_data(boolean sdCardIsExist, String sd_path) {
        this.sdCardIsExist = sdCardIsExist;
        SD_PATH = sd_path;
    }

    public static String getSDPath() {
        if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
            //获取SDCard目录,2.2的时候为:/mnt/sdcard  2.1的时候为：/sdcard，所以使用静态方法得到路径会好一点。
            return Environment.getExternalStorageDirectory().getAbsolutePath();
        }
        return null;
    }
}
